/*********************************************************************************************************/
* REGRESSIONS
/*********************************************************************************************************/

clear all
cls
set more off, permanently

/*********************************************************************************************************/

/* Here you should cd to your root directory and all other paths are then set relative to this  */
cd "/Users/etc/etc"

global dtas "../03_DTAs"
global temp "temp"

/*********************************************************************************************************/
/*********************************************************************************************************/

use $dtas/Regressions_Paper

/*********************************************************************************************************/
* Generate some dummies and regression related stuff. 
/*********************************************************************************************************/

describe

xtset date period 

drop RSV
rename hRSV RSV

gen Lag17_RSV = RSV[_n-17]
gen Lag16_RSV = RSV[_n-16]
gen Lag15_RSV = RSV[_n-15]
gen Lag14_RSV = RSV[_n-14]
gen Lag13_RSV = RSV[_n-13]
gen Lag12_RSV = RSV[_n-12]
gen Lag11_RSV = RSV[_n-11]
gen Lag10_RSV = RSV[_n-10]
gen Lag9_RSV = RSV[_n-9]
gen Lag8_RSV = RSV[_n-8]
gen Lag7_RSV = RSV[_n-7]
gen Lag6_RSV = RSV[_n-6]
gen Lag5_RSV = RSV[_n-5]
gen Lag4_RSV = RSV[_n-4]
gen Lag3_RSV = RSV[_n-3]
gen Lag2_RSV = RSV[_n-2]
gen Lag1_RSV = RSV[_n-1]


/*********************************************************************************************************/

* Regression: Rets on contemporaneous RSV 
est clear

foreach i in 1 2 3 4 5 6 7 8 9 10 11 12{

	cap drop temp1		
	gen temp1=RSV
	
	qui: eststo: reg Rets temp1 if period==`i', rob cluster(month)
	estadd scalar R=100*(e(r2))
	estadd scalar Nobs=e(N)
	
	
}

esttab, nostar nonumbers mtitles("18-19" "19-20" "20-21" "21-22" "22-22" "23-24" "24-01" "01-02" "02-03" "03-04" "04-05" "05-06")   

/*********************************************************************************************************/

* Regression: Rets on 1 hour lagged RSV 


est clear

foreach i in 1 2 3 4 5 6 7 8 9 10 11 12{

	cap drop temp1
	cap drop temp2
	gen temp1=Lag1_RSV
	
	qui: eststo: reg Rets temp1 if period==`i', rob cluster(month)
	estadd scalar R=100*(e(r2))
	estadd scalar Nobs=e(N)
	
	
}


esttab, nostar nonumbers mtitles("18-19" "19-20" "20-21" "21-22" "22-22" "23-24" "24-01" "01-02" "02-03" "03-04" "04-05" "05-06")   


/*********************************************************************************************************/

* Regression: Rets on 12 x 1 hour lagged RSV 

est clear

foreach i in 1 2 3 4 5 6 7 8 9 10 11 12{

	cap drop temp1
	cap drop temp2
	cap drop temp3
	cap drop temp4
	cap drop temp5
	cap drop temp6
	cap drop temp7
	cap drop temp8
	cap drop temp9
	cap drop temp10
	cap drop temp11
	cap drop temp12

	gen temp1=Lag1_RSV
	gen temp2=Lag2_RSV
	gen temp3=Lag3_RSV
	gen temp4=Lag4_RSV
	gen temp5=Lag5_RSV
	gen temp6=Lag6_RSV
	gen temp7=Lag7_RSV
	gen temp8=Lag8_RSV
	gen temp9=Lag9_RSV
	gen temp10=Lag10_RSV
	gen temp11=Lag11_RSV
	gen temp12=Lag12_RSV
	
	qui: eststo: reg Rets temp1 temp2 temp3 temp4 temp5 temp6 ///
	temp7 temp8 temp9 temp10 temp11 temp12 if period==`i', rob cluster(month)
	estadd scalar R=100*(e(r2_a))
	estadd scalar Nobs=e(N)
	
	
}


esttab, nostar nonumbers mtitles("18-19" "19-20" "20-21" "21-22" "22-22" "23-24" "24-01" "01-02" "02-03" "03-04" "04-05" "05-06")   



/*********************************************************************************************************/

* REGRESSION: Rets on closing RSV

est clear

foreach i in 1 2 3 4 5 6 7 8 9 10 11 12{

	cap drop temp1
	local j=`i'+2	
	gen temp1=Lag`j'_RSV
	
	qui: eststo: reg Rets temp1 if period==`i', rob cluster(month)
	estadd scalar R=100*(e(r2))
	estadd scalar Nobs=e(N)
	
}

esttab, nostar nonumbers mtitles("18-19" "19-20" "20-21" "21-22" "22-22" "23-24" "24-01" "01-02" "02-03" "03-04" "04-05" "05-06")   

